//
//  DKPanCardReTakeAlertView.m
//  DanKU
//
//  Created by 吴斌 on 2023/11/27.
//

#import "DKPanCardReTakeAlertView.h"
@interface DKPanCardReTakeAlertView()
@property (nonatomic, weak)zhPopupController * dk_PanCardReTakeAlertPop;
@property (nonatomic,strong)DKPanCardReTakeAlertView *dk_PanCardReTakeAlertView;
@property (nonatomic, copy)void(^SurePanCardReTakeAlertBlock)(void);
@property (nonatomic, copy)void(^DissPanCardReTakeAlertBlock)(void);
@end
@implementation DKPanCardReTakeAlertView
-(instancetype)init{
    if(self == [super init]){
        self.backgroundColor = DK_HexA(@"#000000", 0.7);
        self.layer.cornerRadius = DK_IsWidthScale(18);
        self.clipsToBounds = YES;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UIImageView * dk_photoAlertImgView = [[UIImageView alloc] init];
    dk_photoAlertImgView.image = DK_GetImage(@"dk_AuthCardPhotoError");
    dk_photoAlertImgView.userInteractionEnabled = YES;
    [self addSubview:dk_photoAlertImgView];
    [dk_photoAlertImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(DK_IsWidthScale(78)));
        make.right.equalTo(@(-DK_IsWidthScale(26)));
        make.width.equalTo(@(DK_IsWidthScale(35)));
        make.height.equalTo(@(DK_IsWidthScale(35)));
    }];
    UILabel * dk_AuthCardFrameLab = [[UILabel alloc] init];
    dk_AuthCardFrameLab.textColor = DK_Hex(@"#FFFFFF");
    dk_AuthCardFrameLab.text = @"please retake";
    dk_AuthCardFrameLab.font = DK_FONT_Bold(13);
    dk_AuthCardFrameLab.transform = CGAffineTransformMakeRotation(M_PI/2);
    [self addSubview:dk_AuthCardFrameLab];
    [dk_AuthCardFrameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_left).offset(DK_IsWidthScale(37));
        make.centerY.equalTo(self);
        make.height.equalTo(@(DK_IsWidthScale(18)));
    }];
    [self performSelector:@selector(disCard) withObject:self afterDelay:2.0];
}
- (void)disCard{
    [self.dk_PanCardReTakeAlertPop dismiss];
    if(self.DissPanCardReTakeAlertBlock){
        self.DissPanCardReTakeAlertBlock();
    }
}
+ (void)dk_ShowAuthPanCardReTakeAlertViewComplete:(void(^)(void))complete withDissBlock:(void(^)(void))dissBlock{
    DKPanCardReTakeAlertView * dk_PanCardReTakeAlertView = [[DKPanCardReTakeAlertView alloc] init];
    zhPopupController * surePanCardReTakeAlertCtrl = [[zhPopupController alloc] initWithView:dk_PanCardReTakeAlertView size:CGSizeMake(DK_IsWidthScale(126), DK_IsWidthScale(191.71))];
    dk_PanCardReTakeAlertView.SurePanCardReTakeAlertBlock = complete;
    dk_PanCardReTakeAlertView.DissPanCardReTakeAlertBlock = dissBlock;
    dk_PanCardReTakeAlertView.dk_PanCardReTakeAlertPop = surePanCardReTakeAlertCtrl;
    surePanCardReTakeAlertCtrl.presentationStyle = zhPopupSlideStyleTransform;
    surePanCardReTakeAlertCtrl.maskType = zhPopupMaskTypeClear;
    surePanCardReTakeAlertCtrl.layoutType = zhPopupLayoutTypeCenter;
    surePanCardReTakeAlertCtrl.presentationTransformScale = 0.56;
    surePanCardReTakeAlertCtrl.dismissonTransformScale = 0.56;
    surePanCardReTakeAlertCtrl.dismissOnMaskTouched = NO;
    [surePanCardReTakeAlertCtrl showInView:((AppDelegate*)([UIApplication sharedApplication].delegate)).window completion:^{
    }];
}
@end
